package com.zhou.bjgl.bjgl.business_web.controller;


import com.zhou.bjgl.bjgl.business_web.service.BRoleService;
import com.zhou.bjgl.bjgl.req.b_role.BRoleQueryReq;
import com.zhou.bjgl.bjgl.req.b_user_role.BUserRoleReq;
import com.zhou.bjgl.bjgl.resp.PageResp;
import com.zhou.bjgl.bjgl.resp.common.ApiRestResponse;

import com.zhou.bjgl.bjgl.resp.user_role.BUserRoleResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  权限管理模块
 * </p>
 *
 * @author jz
 * @since 2021-07-16
 */
@RestController
@RequestMapping("/bjgl/b-role")
@Api("权限管理")
public class BRoleController {

    @Resource
    private BRoleService broleService;

    @ApiOperation("添加权限角色")
    @PostMapping("/add")
    public ApiRestResponse add(BRoleQueryReq req) {
        broleService.add(req);
        return ApiRestResponse.success();
    }

    @ApiOperation("给用户授权")
    @PostMapping("/add-user-role")
    public ApiRestResponse addUserRole(BUserRoleReq req){
        broleService.insertRoleMenu(req);
        return ApiRestResponse.success();
    }

    @ApiOperation("获取用户权限列表")
    @GetMapping("/user-role-list")
    public ApiRestResponse getUserRoleList(BUserRoleReq req){
        PageResp<BUserRoleResp> userRoleList=broleService.listUserRoleList(req);
        return ApiRestResponse.success(userRoleList);
    }

    /*public ApiRestResponse editRoles()*/
}

